// pages/recRedpag/index.js
const app = getApp()
var mid;
var rid;
var page = 1;
var pagesize = 12;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    redPackList: [],
  },
  deleteList: function (e) {
    var that = this;
    var data = that.data.reaPackList;
    var index = e.currentTarget.dataset.index;//获取当前长按图片下标
    app.clickLongdeletion(that, data, index,'redPackList');
  },
  //提取收红包记录
  getRedenvelopeReceiveList: function () {
    var that = this;
    var data = [];
    page = 1;
    data['mid'] = mid;
    if(rid && rid !=='' && rid != undefined )
    data['rid'] = rid;
    data['page'] = page;
    data['pagesize'] = pagesize;
    var url = 'We_Redenvelopes/getRedenvelopeCodePassiveList';
    var calkdata = app.netWorkRequest(that, data, url, 'redPackList')
  },

  //加载更多收红包记录
  getRedenvelopeReceiveListLoadMore: function () {
    // 页数+1
    page = page + 1;
    console.log('椰树', page)
    var that = this;
    var data = [];
    data['mid'] = mid;
    if (rid && rid !== '' && rid != undefined)
    data['rid'] = rid;
    data['page'] = page;
    data['pagesize'] = pagesize;
    var url = 'We_Redenvelopes/getRedenvelopeCodePassiveList';
    var f_data = that.data.redPackList;
    var calkdata = app.netWorkRequestLoadMore(that, data, url, 'redPackList', f_data);
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log('reclist首次加载', options)
    page = 1;
    mid = options.mid;
    rid = options.rid;
    this.getRedenvelopeReceiveList();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.getRedenvelopeReceiveList();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    wx.showLoading({
      title: '玩命加载中',
    })
    this.getRedenvelopeReceiveListLoadMore();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})